#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
unsigned char data[330405];
GdkPixbuf *pixbuf;
void my_draw_able_expose (GtkWidget *w, GdkEventExpose *e, gpointer data)
{
    gdk_draw_pixbuf (GTK_WIDGET (w)->window, NULL, pixbuf,0,0,0,0,320,240, GDK_RGB_DITHER_NORMAL, 0, 0);
}

int main (int argc, char *argv[])
{
        GtkWidget *window;
        GtkWidget *draw_able;
        int i,j,pos =0;

        gtk_init (&argc, &argv);


        for ( i = 0; i < 330405; i++)
        {
          data[i] = 0xFF;
        }

        for ( i = 0; i < 240; i++)
        {
          for( j = 0; j < 320; j++)
          {
              data[(i*320+j)*3] = i;
              data[(i*320+j)*3+1] = 0xFF;
              data[(i*320+j)*3+2] = 0xFF;
          }
        }

        window = gtk_window_new( GTK_WINDOW_TOPLEVEL);
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);  

        gtk_signal_connect (GTK_OBJECT (window), "delete_event",
                         GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
        draw_able = gtk_drawing_area_new ();
        gtk_widget_set_size_request (draw_able, 320, 240);
        gtk_container_add (GTK_CONTAINER (window), draw_able);

        g_signal_connect (G_OBJECT (draw_able), "expose_event",
                             GTK_SIGNAL_FUNC(my_draw_able_expose),
                              NULL);

        pixbuf = gdk_pixbuf_new_from_data ((guchar* )data, GDK_COLORSPACE_RGB, 
                   FALSE, 8, 320, 240, 320*3, 0, 0);
       
        gtk_widget_realize(draw_able);
        gtk_widget_show_all(window);
        gtk_main();

     return 0;
}